package ui;
/*
import ui.bind.admin.AdminLogin;
import ui.bind.setting.Setting;
import ui.bind.user.UserLogin;
import ui.test.Newframe;*/

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Bind extends JFrame implements ActionListener {
	private JButton libLoginButton;
	private JButton readerLoginButton;
	private JButton sysLoginButton;
	// private JPanel jp2 = new JPanel();//新面板，用于放置按钮

	public Bind() {
		JFrame jFrame = new JFrame("用户登录");
		jFrame.setLayout(new BorderLayout());
		JPanel jp1 = new JPanel(new GridLayout(1, 3, 20, 100));//设置新面板
		jp1.setBorder(BorderFactory.createTitledBorder("用户登录"));
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

		setTitle("用户登录界面");
		setSize(520, 300);
		setLocationRelativeTo(null);
		

		// 监听右上角的退出按钮
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent windowEvent) {
				System.exit(0);
			}
		});
		ImageIcon lib1 = new ImageIcon("src/image/reader(1).jpg");
		ImageIcon lib2 = new ImageIcon("src/image/librarian0(1).jpg");
		ImageIcon lib3 = new ImageIcon("src/image/sysadmi0(1).jpg");
		
		readerLoginButton = new JButton("读者登录",lib1);
		libLoginButton = new JButton("图书管理员登录",lib2);
		sysLoginButton = new JButton("系统管理员登录",lib3);
		
		jp1.add(readerLoginButton);
		jp1.add(libLoginButton);
		jp1.add(sysLoginButton);
		add(jp1, BorderLayout.SOUTH);
		getContentPane().add(jp1,BorderLayout.CENTER);

		libLoginButton.addActionListener(this);
		readerLoginButton.addActionListener(this);
		
		JButton jb3 = new JButton("返回");
		jb3.addActionListener(this);
		jb3.setActionCommand("back");

		JPanel jp2 = new JPanel();// 新面板，用于放置按钮
		jp2.add(jb3);
		add(jp2, BorderLayout.SOUTH);// 把按钮放到窗口最下方

		this.setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == libLoginButton) {
			this.dispose();
			new AdminLogin();
		} else if (e.getSource() == readerLoginButton) {
			this.dispose();
			new DengLu();
		}else if (e.getActionCommand().equals("back")) {
			this.dispose();
			new Begin();
		}
	}
}


